package com.flynn.rock.crm.entity.customer;

import com.flynn.rock.enums.customer.CustomerOrderStatus;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EntityListeners;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.math.BigDecimal;
import java.time.LocalDateTime;

@Getter
@Setter
@Entity
@Table(name = "crm_customer_order")
@EntityListeners(AuditingEntityListener.class)
public class CustomerOrderEntity {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "customer_order_id", nullable = false)
    private Long customerOrderId;

    @Column(name = "customer_id")
    private Long customerId;

    @Column(name = "customer_code")
    private String customerCode;

    @Column(name = "customer_name")
    private String customerName;

    @Column(name = "phone")
    private String phone;

    @Column(name = "expect_visit_time")
    private LocalDateTime expectVisitTime;

    @Column(name = "actual_visit_time")
    private LocalDateTime actualVisitTime;

    @Column(name = "expect_loan_limit")
    private BigDecimal expectLoanLimit = new BigDecimal("0.00");

    @Column(name = "expect_loan_limit_time")
    private LocalDateTime expectLoanLimitTime;

    @Column(name = "actual_loan_limit")
    private BigDecimal actualLoanLimit = new BigDecimal("0.00");

    @Column(name = "actual_loan_limit_time")
    private LocalDateTime actualLoanLimitTime;

    @Column(name = "create_user_id")
    private Long createUserId;

    @CreatedDate
    @Column(name = "create_time")
    private LocalDateTime createTime;

    @LastModifiedDate
    @Column(name = "update_time")
    private LocalDateTime updateTime;

    @Enumerated(EnumType.STRING)
    @Column(name = "order_status")
    private CustomerOrderStatus orderStatus;

    @Column(name = "remark", length = 64)
    private String remark;
}
